Skip to content

removing function Attributes from the AST tree#1276

Merged
Janther merged 3 commits intomainfrom
skip-variants-2
Oct 8, 2025
Merged

removing function Attributes from the AST tree#1276
Janther merged 3 commits intomainfrom
skip-variants-2

Conversation

@Janther
Copy link
Copy Markdown
Member

@Janther Janther commented Sep 30, 2025

Continuing with extracting variants from PolymorphicNodes.

In this PR

We address the following nodes

  • ConstructorAttribute
  • FallbackFunctionAttribute
  • FunctionAttribute
  • FunctionTypeAttribute
  • ModifierAttribute
  • ReceiveFunctionAttribute
  • StateVariableAttribute
  • UnnamedFunctionAttribute

On top of that, in every collection of these attributes we remove the printVariant as we don't need it anymore and instead of having 2 map functions chained, we just have 1 map to avoid looping twice.

We are also removing multiple destructuring of the variant attribute of these attributes.

Caveat
There was one test scenario that had to be fixed because before one comment would be associated to the PolymorphicNode and another to the variant, and now both of these comments are associated to the same node.

…onAttribute`, `FunctionTypeAttribute`, `ModifierAttribute`, `ReceiveFunctionAttribute`, `StateVariableAttribute`, and `UnnamedFunctionAttribute` from the AST tree
@Janther Janther requested a review from fvictorio September 30, 2025 23:41
Comment thread src/slangPrinter.ts
Comment on lines +66 to +77
Exclude<
StrictAstNode,
| ArgumentsDeclaration
| ConstructorAttribute
| FallbackFunctionAttribute
| FunctionAttribute
| FunctionTypeAttribute
| ModifierAttribute
| ReceiveFunctionAttribute
| StateVariableAttribute
| UnnamedFunctionAttribute
>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only section that for now looks a bit ugly to me, but it gets removed in the last step, for now we need to name every PolymorphicNode that we have successfully removed from the AST tree.

// comment 5
modifier2(/* comment 7 */) // comment 6 // comment 8
modifier2(/* comment 7 */) // comment 6
// comment 8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a mistake, doesn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no, sorry, I saw the unformatted code that corresponds to this result. Makes sense.

@Janther Janther merged commit 177a56f into main Oct 8, 2025
7 checks passed
@Janther Janther deleted the skip-variants-2 branch October 8, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants